<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻</title>
    <style>
        .box {
            width: 300px;
            height: 350px;
            padding: 0 10px;
            /* border: 1px solid gainsboro; */
        }
        .box p:nth-child(1) span{
            color: red;
        }
        .box p:nth-child(2) span{
            color: orange;
        }
        .box p:nth-child(3) span{
            color: yellow;
        }
    </style>
</head>

<body>
    <div class="box">

    </div>
</body>

</html>
<script>
    function ajax(method, url, cb) {
        let xhr = new XMLHttpRequest()
        xhr.open(method, url)
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                cb(JSON.parse(xhr.responseText))
            }
        }
        xhr.send()
    }
    ajax('get', './data.json', function (data) {
        document.querySelector('.box').innerHTML = data.list.map((item) => {
            return `<p><span>${item['id']}</span> ${item['content']}</p>`
        }).join('')
    })
</script>